package com.cumt.framework.rest;

import com.cumt.framework.rest.view.JsonViewResponse;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * Created by caicf on 2016/12/27.
 */
public interface BaseRestServerInterface {

    /**
     * 获取所有数据
     */
    @RequestMapping(value = "/byAll",
            method = RequestMethod.GET,
            produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
    public String getAll();


    /**
     * 分页查询
     * jsonStr格式是有map转换生成，pageJsonStr 对象jsonStr
     */
    @RequestMapping(value = "/byPage",
            method = RequestMethod.POST,
            consumes = {MediaType.APPLICATION_JSON_VALUE},
            produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
    public String getPage(String jsonStr);


    /**
     * 根据条件查询
     * 将条件实体bean转化成jsonStr
     */
    @RequestMapping(value = "/byCondition",
            method = RequestMethod.POST,
            consumes = {MediaType.APPLICATION_JSON_VALUE},
            produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
    public String getByWhere(String jsonStr);


    /**
     * 根据id查询
     */
    @RequestMapping(value = "/{id}",
            method = RequestMethod.GET,
            produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
    public String getById(@PathVariable("id") int id);


    /**
     * 根据id删除
     */
    @RequestMapping(value = "/deleting",
            method = RequestMethod.GET,
            produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
    public String deleteByIds(@RequestParam("id") String ids);


    /**
     * 保存   将实体bean转化成jsonStr
     */
    @RequestMapping(value = "/creating",
            method = RequestMethod.POST,
            consumes = {MediaType.APPLICATION_JSON_VALUE},
            produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
    public String save(String jsonStr);

    /**
     * 编辑   将实体bean转化成jsonStr
     */
    @RequestMapping(value = "/updating",
            method = RequestMethod.POST,
            consumes = {MediaType.APPLICATION_JSON_VALUE},
            produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
    public String update(String jsonStr);

    public String toJsonStr(JsonViewResponse jsonView);
}
